﻿using KalevaAalto.DataPart.Enums;
using KalevaAalto.DataPart.Excel.Base;
using OfficeOpenXml;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace KalevaAalto.DataPart.Excel.Epplus
{
    internal class EpplusPrinterSettings : BasePrinterSettings
    {
        public readonly static double InchOfOneMillimetre = 25.4D;





        public ExcelPrinterSettings _printerSettings;

        public EpplusPrinterSettings(ExcelPrinterSettings printerSettings)
        {
            _printerSettings = printerSettings;
        }


        public override BasePrinterMargin PrinterMargin {
            get => new EpplusPrinterMargin(_printerSettings);
            set => PrinterMargin.Prase(value);
        }
        public override BasePrinterSize PrinterSize { 
            get => new EpplusPrinterSize(_printerSettings); 
            set => PrinterSize.Prase(value); 
        }



        private readonly static CollectionPart.TwoWayDictionary<PrinterPageSizeEnum, ePaperSize> s_printerPageSizeEnum = new CollectionPart.TwoWayDictionary<PrinterPageSizeEnum, ePaperSize>
        {
            { PrinterPageSizeEnum.A4 , ePaperSize.A4 },
            { PrinterPageSizeEnum.A5, ePaperSize.A5 },
        };
        public override PrinterPageSizeEnum PrinterPageSizeEnum 
        { 
            get => s_printerPageSizeEnum.GetValueBySecond(_printerSettings.PaperSize); 
            set => _printerSettings.PaperSize = s_printerPageSizeEnum.GetValueByFirst(value); 
        }



        private readonly static CollectionPart.TwoWayDictionary<PrinterOrientation, eOrientation> s_printerOrientations = new CollectionPart.TwoWayDictionary<PrinterOrientation, eOrientation>
        {
            { PrinterOrientation.Portrait, eOrientation.Portrait },
            { PrinterOrientation.Landscape, eOrientation.Landscape },
        };
        public override PrinterOrientation PrinterOrientation 
        { 
            get => s_printerOrientations.GetValueBySecond(_printerSettings.Orientation); 
            set => _printerSettings.Orientation = s_printerOrientations.GetValueByFirst(value); 
        }
    }
}
